import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import viteSvgIcons from 'vite-plugin-svg-icons';
import path from 'path';

const {resolve} = require("path");

// https://vitejs.dev/config/
export default defineConfig({
    base: './',
    plugins: [
        vue(),
        viteSvgIcons({
            // 配置路劲在你的src里的svg存放文件
            iconDirs: [path.resolve(process.cwd(), 'src/icons/svg')],
            symbolId: 'icon-[name]',
        }),
    ],
    resolve: {
        alias: {
            "@": resolve(__dirname, "./src")
        }
    },
    css: {
        postcss: {
          plugins: [
            {
              postcssPlugin: 'internal:charset-removal',
              AtRule: {
                charset: (atRule) => {
                  if (atRule.name === 'charset') {
                    atRule.remove();
                  }
                }
              }
            }
          ]
        }
      },
    server: {
        port: 9528, // 服务端口
        proxy: { // 代理
            '/gateway': {
                target: 'http://localhost:8180',
                //target: 'http://dev-os.roncoos.com/gateway',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/gateway/, '')
            }
        },
    },
})
